#include <iostream>
#include <algorithm>
using namespace std;

const int N = 100010;

int n;
int a[N];
int res = 0;

int main()
{
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    sort(a, a + n);
    for (int i = 0, j = n - 1; i < n; ++i, --j)
        res = res + a[i] * j;
    cout << res;
}